#ifndef __ADS8684_H
#define __ADS8684_H

#include "main.h"


#define ADS8698_NUM_CHANNELS 8

#define ADS8698_CMD_REG(x) (x << 8)
#define ADS8698_CMD_REG_NOOP 0x00
#define ADS8698_CMD_REG_RST 0x85
#define ADS8698_CMD_REG_MAN_CH(chan) (0xC0 | (4 * chan))
#define ADS8698_CMD_DONT_CARE_BITS 16

#define ADS8698_PROG_REG(x) (x << 9)
#define ADS8698_PROG_REG_RANGE_CH(chan) (0x05 + chan)
#define ADS8698_PROG_W_BIT 1
#define ADS8698_PROG_R_BIT 0
#define ADS8698_PROG_DONT_CARE_BITS 8

typedef struct
{
    uint8_t chan;

    SPI_HandleTypeDef *spix;

    GPIO_TypeDef *gpio_cs;
    uint16_t gpio_pin_cs;
    GPIO_PinState cs_valid;

    uint16_t data[ADS8698_NUM_CHANNELS];

} t_ads8684, *p_ads8684;

#endif
